//
// Created by 11510 on 2024/6/7.
//
#include <iostream>
#include <string.h>
#include <vector>
using std::cout;
using std::endl;
using std::vector;

/**
 * vector的构造
 */
void test0(){
    vector<int> vec1;
    vector<long> vec2(8);

    for(auto &ele : vec2){
//        cout << ele << endl;
    }

    vector<long> vec3(10, 666);
    for (const auto &item: vec3) {
//        cout << item << endl;
    }

    vector<int> vec4{1, 2, 3, 4, 5};
    vector<int>::iterator  it = vec4.begin();
    vector<int>::iterator it2 = vec4.end();
    it2--;
    vector<int> vec5(it, it2);
    for (const auto &item: vec4) {
        cout << item;
    }
}

/**
 * vector的遍历
 */
void test1(){
    vector<int> vec1{1, 2, 3, 4, 5};
    for (int i = 0; i < vec1.size(); ++i) {
//        cout << vec1[i] << " ";
    }

    vector<int>::iterator it = vec1.begin();
    for (; it != vec1.end(); it++) {
        cout << *it << " ";
    }
}

/**
 * vector的常用操作
 */
void test2(){
    vector<int> vec1{1, 2, 3, 4, 5};
    vec1.push_back(8);
    vec1.push_back(9);
    vec1.push_back(10);
    cout << vec1.empty() << endl;
    cout << vec1.size() << endl;
    cout << vec1.capacity() << endl;

}

int main(int argc, char *argv[]){
    test2();
    return 0;
}